<?php
/**
 * Created by PhpStorm.
 * User: lawmil
 * Date: 16/10/25
 * Time: 14:20
 */
if (!defined('IN_ANWSION'))
{
    die;
}
class main extends AWS_CONTROLLER
{

    public function get_access_rule()
    {
        $rule_action['rule_type'] = "white"; //'black'黑名单,黑名单中的检查  'white'白名单,白名单以外的检查

        if ($this->user_info['permission']['visit_chapter'] AND $this->user_info['permission']['visit_site'])
        {
            $rule_action['actions'][] = 'index';
        }

        return $rule_action;
    }

    public function index_action()
    {
        if (!$_GET['page'])
        {
            $_GET['page'] = 1;
        }

        $list = $this->model('follow')->get_user_friends_by_true($this->user_id,calc_page_limit($_GET['page'], get_setting('contents_per_page')));
        TPL::assign('friends_list', $list);
        TPL::assign('pagination', AWS_APP::pagination()->initialize(array(
            'base_url' => get_js_url('/friend/group_id-' . $_GET['group_id']),
            'total_rows' => $this->model('follow')->get_user_friends_by_true_count($this->user_id),
            'per_page' => get_setting('contents_per_page')
        ))->create_links());
        TPL::output('friend/index');
    }

    public function follow_action()
    {
        $list = $this->model('follow')->get_user_fans($this->user_id, calc_page_limit($_GET['page'], get_setting('contents_per_page')));
        TPL::assign('follow_list', $list);
        TPL::assign('pagination', AWS_APP::pagination()->initialize(array(
            'base_url' => get_js_url('/friend/follow/group_id-' . $_GET['group_id']),
            'total_rows' => $this->model('follow')->get_user_fans_count($this->user_id),
            'per_page' => get_setting('contents_per_page')
        ))->create_links());
        TPL::output('friend/follow');
        
    }

    public function fans_action()
    {
        $list = $this->model('follow')->get_user_friends($this->user_id, calc_page_limit($_GET['page'], get_setting('contents_per_page')));
        TPL::assign('fans_list', $list);
        TPL::assign('pagination', AWS_APP::pagination()->initialize(array(
            'base_url' => get_js_url('/friend/fans/group_id-' . $_GET['group_id']),
            'total_rows' => $this->model('follow')->get_user_friends_by_true_count($this->user_id),
            'per_page' => get_setting('contents_per_page')
        ))->create_links());
        TPL::output('friend/fans');

    }

    public function find_action()
    {
        TPL::output('friend/find');
    }

}